package com.news.service.impl;

import com.news.mapper.CategoryMapper;
import com.news.model.Category;
import com.news.model.CategoryExample;
import com.news.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceImpl implements CategoryService {
    @Autowired
    private CategoryMapper categoryMapper;


    @Override
    public void insertCategory(Category category) {
        System.out.println(category);
        categoryMapper.insert(category);
    }

    @Override
    public List<Category> queryAll(int pageNum, int pageSize) {
    /*    PageHelper.startPage(pageNum,pageSize);*/
        CategoryExample ce =new CategoryExample();
        ce.setDistinct(false);
        List<Category> categories = categoryMapper.selectByExample(ce);
        System.out.println(categories);
        return categories;
    }

    @Override
    public Category queryOne(String id) {
        return categoryMapper.selectByPrimaryKey(id);
    }

    @Override
    public void update(Category category) {
        categoryMapper.updateByPrimaryKeySelective(category);
    }

}
